const path = require("path");
// commentjs 引入 node
const HtmlWebpackPlugin = require("html-webpack-plugin");

module.exports = {
  mode: "development",

  entry: "./src/index.js",

  devtool: "inline-source-map",

  devServer: {
    static: "./dist",
  },

  plugins: [
    new HtmlWebpackPlugin({
      title: "管理输出",
      template: "src/index.html",
    }),
  ],

  output: {
    filename: "bundle.[contenthash].js",
    path: path.resolve(__dirname, "dist"),
    clean: true,
  },
  module: {
    rules: [
      {
        test: /\.css$/i,
        use: ["style-loader", "css-loader"],
        // 多个loader 顺序 倒叙
      },
      {
        test: /\.(png|svg|jpg|jpeg|gif)$/i,
        type: "asset/resource",
      },
    ],
  },
};
